package com.qf.service.caiwu_service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.qf.bean.Prefund;
import com.qf.bean.PrefundRule;
import com.qf.dao.caiwu_dao.PrefundMapper;
import com.qf.service.caiwu_service.PrefundService;
import com.qf.utils.caiwu.enums.PrefundBalanceStateEnum;
import com.qf.utils.caiwu.vo.PrefundReportVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * 2019/12/12 0012
 * Author->DT
 * sassspringboot
 * 行到水穷处 坐看云起时
 * 模块：
 */
@Service
public class PrefundServiceImpl implements PrefundService {
    @Autowired
    private PrefundMapper prefundMapper;

    //分页查询预存款信息列表
    @Override
    public PageInfo<Prefund> findPrefundListByLimit(Map map) {
        //开启分页
        PageHelper.startPage((int)map.get("index"),(int)map.get("page"));
        //查询预存款信息列表
        List<Prefund> list=prefundMapper.findDeptList(map);
        //封装PageInfo
        return new PageInfo<>(list);
    }

    //分页查询预存款报表信息
    @Override
    public PageInfo<PrefundReportVO> findPrefundReportByLimit(Map map) {
        //开启分页
        PageHelper.startPage((int)map.get("index"),(int)map.get("page"));
        //查询预存款报表信息列表
        List<PrefundReportVO> list=prefundMapper.findPrefundReportList(map);
        //pageInfo
        PageInfo<PrefundReportVO> pageInfo = new PageInfo<>(list);
        return pageInfo;
    }

    //新增
    @Override
    public int insertSelective(Prefund record) {
        //设置可用余额和总额为0
        record.setUsedBalance(0.0);
        record.setTotalMoney(0.0);
        //设置余额状态为余额为零
        record.setBalanceState(PrefundBalanceStateEnum.ZERO_BALANCE.getState());
        //新增
        return prefundMapper.insertSelective(record);
    }

    //查询全部客户信息：客户姓名+pid
    @Override
    public List<Prefund> findAllClient() {
        return prefundMapper.findAllClient();
    }
}
